# 简单的文件读取验证用户名密码
# def login(username,password):
#     with open("db","r+",encoding="utf-8")as fp:
#         for line in fp:
#             line = line.strip()
#             list_data = line.split("$")
#             if(list_data[0] == username and list_data[1] == password):
#                 print("登陆成功")
#                 return True
#     print("登陆失败")
#     return False
# user = input("请输入用户名:")
# password = input("请输入密码:")
# login(username=user,password=password)
def register(user, password):
    with open("db", "r+", encoding="utf-8") as fp:
        for line in fp:
            line = line.strip()
            list_data = line.split("$")
            if list_data[0] == user:
                print("账号已经存在注册失败")
                return False
        data = "\n" + user + "$" + password
        fp.write(data)
        print("恭喜注册成功")
        return True


username = input("请输入注册的用户名:")
passwor = input("请输入注册的密码:")
register(username, passwor)
